home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmODBCLogon
- BorderStyle = 3 'Fixed Dialog
- Caption = "ODBC Logon"
- ClientHeight = 2325
- ClientLeft = 2625
- ClientTop = 2865
- ClientWidth = 4470
- ControlBox = 0 'False
- BeginProperty Font
- Name = "Tahoma"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- HelpContextID = 2016138
- LinkTopic = "Form1"
- LockControls = -1 'True
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2325
- ScaleWidth = 4470
- ShowInTaskbar = 0 'False
- Begin VB.CommandButton cmdCancel
- Cancel = -1 'True
- Caption = "Cancel"
- Height = 360
- Left = 2340
- MaskColor = &H00000000&
- TabIndex = 9
- Top = 1875
- Width = 1260
- End
- Begin VB.CommandButton cmdOK
- Caption = "&OK"
- Default = -1 'True
- Height = 360
- Left = 870
- MaskColor = &H00000000&
- TabIndex = 8
- Top = 1875
- Width = 1260
- End
- Begin VB.Frame fraConnection
- Caption = "Connection Values"
- Height = 1665
- Left = 120
- TabIndex = 10
- Top = 120
- Width = 4230
- Begin VB.TextBox txtUID
- Height = 300
- Left = 1125
- TabIndex = 3
- Top = 600
- Width = 3015
- End
- Begin VB.TextBox txtPWD
- Height = 300
- IMEMode = 3 'DISABLE
- Left = 1125
- PasswordChar = "*"
- TabIndex = 5
- Top = 930
- Width = 3015
- End
- Begin VB.TextBox txtDatabase
- Height = 300
- Left = 1125
- TabIndex = 7
- Top = 1260
- Width = 3015
- End
- Begin VB.ComboBox cboDSNList
- Height = 315
- Left = 1125
- Sorted = -1 'True
- TabIndex = 1
- Top = 240
- Width = 3000
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "&DSN:"
- Height = 195
- Index = 0
- Left = 135
- TabIndex = 0
- Top = 285
- Width = 360
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "&UID:"
- Height = 195
- Index = 1
- Left = 135
- TabIndex = 2
- Top = 630
- Width = 330
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "&Password:"
- Height = 195
- Index = 2
- Left = 135
- TabIndex = 4
- Top = 975
- Width = 750
- End
- Begin VB.Label lblLabels
- AutoSize = -1 'True
- Caption = "Data&base:"
- Height = 195
- Index = 3
- Left = 135
- TabIndex = 6
- Top = 1320
- Width = 750
- End
- End
- Attribute VB_Name = "frmODBCLogon"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Public bOk As Boolean
- Private Declare Function SQLDataSources Lib "ODBC32.DLL" (ByVal henv&, ByVal fDirection%, ByVal szDSN$, ByVal cbDSNMax%, pcbDSN%, ByVal szDescription$, ByVal cbDescriptionMax%, pcbDescription%) As Integer
- Private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&)
- Const SQL_SUCCESS As Long = 0
- Const SQL_FETCH_NEXT As Long = 1
- Private Sub cmdCancel_Click()
- bOk = False
- Me.Hide
- End Sub
- Private Sub cmdOK_Click()
- bOk = True
- Me.Hide
- End Sub
- Private Sub Form_Load()
- GetDSNsAndDrivers
- End Sub
- Sub GetDSNsAndDrivers()
- On Error Resume Next
- Dim i As Integer
- Dim sDSNItem As String * 1024
- Dim sDRVItem As String * 1024
- Dim sDSN As String
- Dim sDRV As String
- Dim iDSNLen As Integer
- Dim iDRVLen As Integer
- Dim lHenv As Long 'handle to the environment
- 'get the DSNs
- If SQLAllocEnv(lHenv) <> -1 Then
- Do Until i <> SQL_SUCCESS
- sDSNItem = String(1024, " ")
- sDRVItem = String(1024, " ")
- i = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, iDSNLen, sDRVItem, 1024, iDRVLen)
- sDSN = VBA.Left(sDSNItem, iDSNLen)
- If sDSN <> String(iDSNLen, " ") Then cboDSNList.AddItem sDSN
- Loop
- End If
- cboDSNList.ListIndex = 0
- End Sub
-